#include("../common/header.html")
<body>
	<div id="container" style="background-color:#F5F5F5;top:0vh;height:100vh;">
		<div class="topItems flex">
			#if(profit.recVal3?? && profit.recVal1>0)
			<div class="topItem #(className) seltop" id="class1" level="1" >一级(邀请好友)</div>
			#end
			#if(profit.recVal3?? && profit.recVal2>0)
			<div class="topItem #(className)" id="class2" level="2" >二级(邀请好友)</div>
			#end
			#if(profit.recVal3?? && profit.recVal3>0)
			<div class="topItem #(className)" id="class3" level="3" >三级(邀请好友)</div>
			#end
		</div>
		<div>
			<div class="class1">
			</div>
			<div class="class2" style="display: none;">
			</div>
			<div class="class3" style="display: none;">
			</div>
		</div>
	</div>
</body>
<script>


	$(document)[0].title="我的团队";
	(function (){
		var page=1;
		var level = 1;
		var html='';
		var arr=[]

		this.grouplist=function(){
			$.ajax({
				type: "GET",
				url: "#(ctx)/wap/member/group",
				data:{'act':'ajaxpage','level':level,'page':page},
				dataType: "json",
				success: function(data){
					
					for(var i in data){
						arr.push(data[i])
					}
		        	if(arr.length==0){
		        		$(".class"+level).html('<p style="text-align:center">暂无数据</p>');
		        	}
					if(data.length>0){
						$.each(data, function(idx, obj) {
							html = `<div class="cash between">
										<div class="groupL cahsL flex">
											<img src="`+obj.avatar+`" alt="">
											<div style="max-width:30vw;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">`+obj.nickname+`</div>
										</div>
										<div class="groupR">`+obj.ctime+`</div>
									</div>`;
							$(".class"+level).append(html);
						});
						page++;
					}
				}
			});
		}
		 $(".topItems>.topItem").on("click",function(){
        	$(this).addClass("seltop").siblings().removeClass("seltop");
        	$("."+$(this).attr("id")).css("display","block").siblings().css("display","none");
        	level = $(this).attr("level");
        	page = 1;
        	arr=[]
        	$(".class"+level).empty();
	        window.grouplist();
        })


		this.grouplist();


        var nScrollHight = 0; //滚动距离总长(注意不是滚动条的长度)
        var nScrollTop = 0;   //滚动到的当前位置
        var nDivHight = $("#container").height();
        $("#container").scroll(function(){
        	nScrollHight = $(this)[0].scrollHeight;
        	nScrollTop = $(this)[0].scrollTop;
        	if(nScrollTop + nDivHight >= nScrollHight){
        		// alert("滚动条到底部了");
        		console.log("到底了",window);
        		window.grouplist();
        	}
        });

       
    })()
</script>
</html>